<?php
namespace app\index\controller;

use app\common\controller\Frontend;
use app\common\library\Token;
use app\index\model\Index as IndexModel;

class Index extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';
    protected $indexmodel= null; 

    public function _initialize()
    {
        parent::_initialize();
        $this->indexmodel=new IndexModel;

    }

    public function index()
    {
        $where_nav['switch'] =1; 
        $nav = $this->indexmodel->findAllByWhere('nav',$where_nav,"*","weigh desc");
        $banner = $this->indexmodel->loadAllData('banner',"*",$where_nav,1,4,"weigh desc");
        $about = $this->indexmodel->findByAttributes('about',$where_nav,"*");
        $service = $this->indexmodel->loadAllData('service',"*",$where_nav,1,5,"weigh desc");
        $about['images']=explode(",",$about['images']);
        $pro = $this->indexmodel->loadAllData('portfolio',"*",$where_nav,1,12,"weigh desc");
        $team = $this->indexmodel->loadAllData('team',"*",$where_nav,1,12,"weigh desc");
        $blog = $this->indexmodel->loadAllData('archive',"id,title,createtime,writer,image,desc",$where_nav,1,3,"weigh desc");

        $this->view->assign("pro", $pro);
        $this->view->assign("blog", $blog);
        $this->view->assign("team", $team);
        $this->view->assign("pros", $pro);
        $this->view->assign("banner", $banner);
        $this->view->assign("service", $service);
        $this->view->assign("about", $about);
        $this->view->assign("nav", $nav);
        return $this->view->fetch();
    }

    public function news()
    {
        $newslist = [];
        return jsonp(['newslist' => $newslist, 'new' => count($newslist), 'url' => 'https://www.fastadmin.net?ref=news']);
    }

}
